home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
message.zip
/
MESSAGE.ASC
< prev
next >
Wrap
Text File
|
1992-11-10
|
37KB
|
849 lines
0 /*
1 ╔════════════════════════════════════════════════════════════════════════════╗
2 ║ MESSAGE MINDER ║
3 ║ ║
4 ║ By Brian Hill March, 1992 ║
5 ║ ║
6 ║ Message minder is a TSR program which will display a message ║
7 ║ from the serial port on the screen. The message is cleared when the ║
8 ║ user presses any key. The format for sending a messge is as follows: ║
9 ║ 1) The com port on the sending machine should be set to 9600, N, 8, 1. ║
10 ║ 2) A message is started with a SOH character. <alt> 1 will generate. ║
11 ║ 3) A message is completed with a EOT character. <alt> 4 will generate. ║
12 ║ ║
13 ║ *NOTE when the user enters the un-install command: message u the program ║
14 ║ will only un-install properly if it is the last TSR loaded. ║
15 ║ ║
16 ╚════════════════════════════════════════════════════════════════════════════╝
17 */
18 #pragma check_stack( off ) // turn off stack checking
19 #pragma check_pointer( off ) // do not check for null pointers
20 #pragma pack(1) // byte align data to conserve memory
21
22 #include <string.h>
23 #include <stdlib.h>
24 #include < conio.h>
25 #include < stdio.h>
26 #include < bios.h>
27 #include < dos.h>
28
29 #define SOH 1 // start of header
30 #define EOT 4 // end of transmit
31 #define ESC 27 // ASCII value of escape key
32 #define ENTER 13 // ASCII value for enter key
33 #define BACKSPACE 8 // ASCII value for backspace key
34 #define NORM_VID 7 // normal video attribute
35
36
37 /*
38 ╔════════════════════════════════════════════════════════════════════════════╗
39 ║ Interrupt routines and function pointers ║
40 ╚════════════════════════════════════════════════════════════════════════════╝
41 */
42 void (interrupt _far *oldclock)(void); // old clock handler
43 void (interrupt _far *olddosok)(void); // old dosok handler
44 void (interrupt _far *oldkeybd)(void); // old keyboard handler
45 void interrupt _far keybd(void); // our keyboard handler
46 void interrupt _far clock(void); // our clock routine
47 void interrupt _far dosok(void); // our dosok handler
48 void interrupt _far serial(void); // Our serial port ISR
49
50
51
52
53
54 /*
55 ╔════════════════════════════════════════════════════════════════════════════╗
56 ║ Functions our program will call when active ║
57 ╚════════════════════════════════════════════════════════════════════════════╝
58 */
59 void memputs(char x,char y,char *string,char attrib); // display string
60 void save_screen(void); // save user's screen in screen[]
61 void restore_screen(void); // restore user's screen
62 void display_message(void); // display our message to screen
63 void draw_border(int type); // make a message border
64 void doit(void); // activate TSR
65 void memputs(char x, char y,char *string, char attrib);
66 void send_message(void); // Get message and transmit
67 void display_message(void); // show received message
68 void xmit_char(char ch); // sent a character out COM 1
69 int chk_xmit(void); // Is it OK to send a character?
70 int mem_gets(char *szStr,int xyStrRow, int xyStrCol); // get a string
71 void write_char(int x,int y,char ch,char attrib); // write char at x,y
72 void goto_xy(int x, int y); // move cursor
73 void get_xy(int *x, int *y); // get cursor pos -w- BIOS
74 void beep(void); // short "beep" thru PC's speaker
75
76 void main();
77 void init(void); // set up program
78 int check_install(int num); // check if program resident
79 void interrupt _far un_install (void); // pointer to un-install function
80
81 /*
82 ╔════════════════════════════════════════════════════════════════════════════╗
83 ║ Program data ║
84 ╚════════════════════════════════════════════════════════════════════════════╝
85 */
86 char buffer[81]; // our serial input buffer
87 char userscreen[481]; // save user's screen here
88 int port; // com1 port address
89 int _far *keyboard_status; // check if <ctrl> is pressed.
90 char _far *video = (char far *)0xB8000000; // pointer to color video memory
91 char _far *mode = (char far *)0x00400049; // pointer to CRT video mode
92
93 char _huge *tsrstack; // our stack space
94 char _huge *tsrbottom; // huge pointer to our PSP
95 char _huge *userstack; // user's stack space
96
97 char string[] = {"_MESSAGE"}; // TSR signature
98 struct tsrinfo
99 {
100 char *signature; // pointer to TSR signature
101 void (interrupt _far *un_install_ptr)(void); // pointer to un-install
102
103 } transient, _huge *resident;
104
105
106
107
108 /*
109 ╔════════════════════════════════════════════════════════════════════════════╗
110 ║ Flags ║
111 ╚════════════════════════════════════════════════════════════════════════════╝
112 */
113 char _far request_to_run; // Has message arrived?
114 char _far tsr_running; // Is menu displayed?
115 _segment(dosseg); // Segment of inDos flag.
116 char _based(dosseg) *indos; // Based pointer to InDos flag.
117 char video_mode_flag; // Waiting for appropriate video mode?
118
119
120 /*
121 ╔════════════════════════════════════════════════════════════════════════════╗
122 ║ Code ║
123 ╚════════════════════════════════════════════════════════════════════════════╝
124 */
125 void main(int argc, char **argv)
126 {
127
128 unsigned tsrsize; // memory needed for residence
129 int i; // a scratch pad variable
130 char ch;
131
132 /*
133 ╔═════════════════════════════════════════════════════════════════════╗
134 ║ Claculate program size ║
135 ╚═════════════════════════════════════════════════════════════════════╝
136 */
137 _asm mov WORD PTR tsrstack[0], sp // save our stack address
138 _asm mov WORD PTR tsrstack[2], ss
139 FP_SEG(tsrbottom) = _psp; // save PSP address
140 FP_OFF(tsrbottom) = 0;
141 tsrsize = ((tsrstack - tsrbottom) >> 4) + 1; // calculate program size
142
143 /*
144 ╔═════════════════════════════════════════════════════════════════════╗
145 ║ Is the program already installed? ║
146 ╚════════════════════════